package com.example.javafx.hbox;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

/**
 * 设置HBOX 首选宽度
 */
public class Main_3 extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("");
        Group root =new Group();
        Scene scene = new Scene(root,300,250, Color.WHITE);

        HBox hBox = new HBox();
        Button button1 = new Button("Add    ");
        Button button2 = new Button("Remove     ");
        HBox.setHgrow(button1, Priority.ALWAYS);
        HBox.setHgrow(button2,Priority.ALWAYS);
        hBox.getChildren().addAll(button1,button2);
        hBox.setPrefWidth(400);
        root.getChildren().add(hBox);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
